﻿using System;
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.CoreGraphics;
using Beauty.Module.Pos;
 
namespace Beauty
{
	public partial class SideMenuController : BaseController
	{
		public SideMenuController() : base(null, null)
		{
		}

		public override void ViewDidLoad()
		{
			base.ViewDidLoad();
			View.BackgroundColor =  UIColorExtensions.FromHexString("#2e2727");

			UIImageView title = new UIImageView(new UIImage("WCNav_1.png"));

			title.Frame = new RectangleF (0, 0, 400, 180);
 
			 

			UIImageView avatar = new UIImageView(new UIImage("avatar.png"));
			avatar.Frame = new RectangleF(0, 0, 80, 80);
			avatar.Center = new PointF (200, 60);
			UILabel lbName = new UILabel (new RectangleF (140, 105, 200, 40));
			lbName.Text = "Manager Name";
			lbName.TextColor = UIColor.White;
			//lbName.Font = UIFont.BoldSystemFontOfSize (18f);
			lbName.Font=UIFont.SystemFontOfSize (18f);
			UILabel lbPos = new UILabel (new RectangleF(170,125,80,40));
			lbPos.Text="Manager";
		 
			lbPos.Font=UIFont.SystemFontOfSize (16f);
			lbPos.TextColor = UIColorExtensions.FromHexString("#929292");
			#region temp
			//title.Add (lbName);
			//title.Add (lbPos);
			//			introButton.TouchUpInside += (sender, e) => {
			//				NavController.PopToRootViewController(false);
			//				SidebarController.CloseMenu();
			//			};
			title.AddSubview (avatar);
			title.Add(lbPos);
			title.Add(lbName);
			var contentButton = new UIButton(UIButtonType.System);
			contentButton.Frame = new RectangleF(0, 220, 230, 20);
			contentButton.SetTitle("Content", UIControlState.Normal);
			contentButton.TouchUpInside += (sender, e) => {
				NavController.PushViewController(new ContentController(), false);
				SidebarController.CloseMenu();
			};
			#endregion
			UIView ContentMenu = new UIView (new RectangleF (0, title.Frame.Height, title.Frame.Width, 768 - title.Frame.Height));
			Console.WriteLine ("r View=" + View.Frame.Width + " c View=" + View.Frame.Height + " c Content=" + (View.Frame.Height - title.Frame.Height).ToString ());
			ContentMenu.BackgroundColor =  UIColorExtensions.FromHexString("#2e2727");

			UIView[] listMenu = new UIView[] {

				new UIView (new RectangleF (0, 0, 133, 145)), new UIView (new RectangleF (1 * 133, 0, 133, 145)), new UIView (new RectangleF (2 * 133, 0, 133, 145)),
				new UIView (new RectangleF (0, 145, 133, 145)), new UIView (new RectangleF (1 * 133, 145, 133, 145)), new UIView (new RectangleF (2 * 133, 145, 133, 145)),
				new UIView (new RectangleF (0, 145 * 2, 133, 145)), new UIView (new RectangleF (1 * 133, 145 * 2, 133, 145)), new UIView (new RectangleF (2 * 133, 145 * 2, 133, 145)),
				new UIView (new RectangleF (0, 145 * 3, 133, 145)), new UIView (new RectangleF (1 * 133, 145 * 3, 133, 145)), new UIView (new RectangleF (2 * 133, 145 * 3, 133, 145))
			  
			};
			//row 1
			UIButton cmdPos = new UIButton (UIButtonType.Custom);
			UIImage imagePos = PosUtility.ImageFrom("cas_1");
			UIImage imagePosTouched = PosUtility.ImageFrom("cas_2");
			cmdPos.SetBackgroundImage (imagePos,UIControlState.Normal);
			cmdPos.SetBackgroundImage (imagePosTouched,UIControlState.Highlighted);
			cmdPos.Frame = new RectangleF (0, 0, 50, 50);
			cmdPos.Center = new PointF (listMenu [0].Frame.Width / 2, listMenu [0].Frame.Height / 2);
			cmdPos.TouchUpInside += (object sender, EventArgs e) => {
				NavController.PushViewController(new PosCtrl(),false);
				SidebarController.CloseMenu();
			};
			cmdPos.Layer.ZPosition = 1000f;
			UILabel titlePos = new UILabel (new RectangleF ( 0, 0, 100, 30));
			titlePos.Text="POS";
			titlePos.Font=UIFont.SystemFontOfSize (14f);
			titlePos.TextColor = UIColorExtensions.FromHexString("#929292");
			titlePos.LineBreakMode=UILineBreakMode.WordWrap;
			titlePos.Center = new PointF (listMenu [0].Frame.Width / 2 +35 , listMenu [0].Frame.Height / 2 + 30 );
			titlePos.Layer.ZPosition = 1000; 
			listMenu [0].Add (titlePos); 
			listMenu [0].Add (cmdPos);
				 
			UIButton cmdAct = new UIButton (UIButtonType.Custom);
			UIImage imageAct = PosUtility.ImageFrom ("act_1");
			UIImage imageActTouched =    PosUtility.ImageFrom ("act_2");
			cmdAct.SetBackgroundImage (imageAct,UIControlState.Normal);
			cmdAct.SetBackgroundImage (imageActTouched,UIControlState.Highlighted);
			cmdAct.Frame = new RectangleF (0, 0, 50, 50);
			cmdAct.Center = new PointF (listMenu [1].Frame.Width / 2, listMenu [1].Frame.Height / 2);
			UILabel titleAct = new UILabel (new RectangleF ( 0, 0, 100, 30));
			titleAct.Text="Activities";
			titleAct.TextColor = UIColorExtensions.FromHexString("#929292");
			titleAct.LineBreakMode=UILineBreakMode.WordWrap;
			titleAct.Center = new PointF (listMenu [1].Frame.Width / 2 + 20, listMenu [1].Frame.Height / 2 + 30);
			titleAct.Font=UIFont.SystemFontOfSize (14f);
			listMenu [1].Add (titleAct); 
			listMenu [1].Add (cmdAct);


			UIButton cmdCash = new UIButton (UIButtonType.Custom);
			UIImage imageCash = PosUtility.ImageFrom("cash_1");
			UIImage imageCashTouched = PosUtility.ImageFrom ("cash_2");
			cmdCash.SetBackgroundImage (imageCash,UIControlState.Normal);
			cmdCash.SetBackgroundImage (imageCashTouched,UIControlState.Highlighted);
			cmdCash.Frame = new RectangleF (0, 0, 50, 50);
			cmdCash.Center = new PointF (listMenu [2].Frame.Width / 2, listMenu [2].Frame.Height / 2);
			UILabel titleJCash1 = new UILabel (new RectangleF ( 0, 0, 100, 30));
			titleJCash1.Text="Cash";
			titleJCash1.TextColor = UIColorExtensions.FromHexString("#929292");
			titleJCash1.Center = new PointF (listMenu [2].Frame.Width / 2 + 30, listMenu [2].Frame.Height / 2 + 30);
			titleJCash1.Font=UIFont.SystemFontOfSize (14f);
			UILabel titleJCash2= new UILabel (new RectangleF ( 0, 0, 100, 30));
			titleJCash2.Text="Management";
			titleJCash2.TextColor = UIColorExtensions.FromHexString("#929292");
			titleJCash2.Center = new PointF (listMenu [2].Frame.Width / 2 + 5 , listMenu [2].Frame.Height / 2 + 50);
			titleJCash2.Font=UIFont.SystemFontOfSize (14f);
			listMenu [2].Add (titleJCash1); 
			listMenu [2].Add (titleJCash2); 
			listMenu [2].Add (cmdCash);
			//row 2
			UIButton cmdJobdb = new UIButton (UIButtonType.Custom);
			UIImage imageJobdb = PosUtility.ImageFrom("jobdb_1");
			UIImage imageJobdbTouched = PosUtility.ImageFrom ("jobdb_2");
			cmdJobdb.SetBackgroundImage (imageJobdb,UIControlState.Normal);
			cmdJobdb.SetBackgroundImage (imageJobdbTouched,UIControlState.Highlighted);
			cmdJobdb.Frame = new RectangleF (0, 0, 50, 50);
			cmdJobdb.Center = new PointF (listMenu [3].Frame.Width / 2, listMenu [3].Frame.Height / 2);
			UILabel titleJobdb1 = new UILabel (new RectangleF ( 0, 0, 100, 30));
			titleJobdb1.Text="Job";
			titleJobdb1.Font=UIFont.SystemFontOfSize (14f);
			titleJobdb1.Center = new PointF (listMenu [3].Frame.Width / 2 + 35, listMenu [3].Frame.Height / 2 + 30);
			titleJobdb1.TextColor = UIColorExtensions.FromHexString("#929292");
			UILabel titleJobdb2 = new UILabel (new RectangleF ( 0, 0, 100, 30));
			titleJobdb2.Text="Dashboard";
			titleJobdb2.Font=UIFont.SystemFontOfSize (14f);
			titleJobdb2.TextColor = UIColorExtensions.FromHexString("#929292");
			titleJobdb2.Center = new PointF (listMenu [3].Frame.Width / 2 + 15, listMenu [3].Frame.Height / 2 + 50);
			listMenu [3].Add (titleJobdb1);
			listMenu [3].Add (titleJobdb2);
			listMenu [3].Add (cmdJobdb);

			UIButton cmdjobsh = new UIButton (UIButtonType.Custom);
			UIImage imagejobsh = PosUtility.ImageFrom("jobsh_1");
			UIImage imagejobshTouched = PosUtility.ImageFrom ("jobsh_2");
			cmdjobsh.SetBackgroundImage (imagejobsh,UIControlState.Normal);
			cmdjobsh.SetBackgroundImage (imagejobshTouched,UIControlState.Highlighted);
			cmdjobsh.Frame = new RectangleF (0, 0, 50, 50);
			cmdjobsh.Center = new PointF (listMenu [4].Frame.Width / 2, listMenu [4].Frame.Height / 2);
			UILabel titleJobs = new UILabel (new RectangleF ( 0, 0, 100, 30));
			titleJobs.Text="Jobsheets";
			titleJobs.TextColor = UIColorExtensions.FromHexString("#929292");
			titleJobs.Font=UIFont.SystemFontOfSize (14f);
			titleJobs.Center = new PointF (listMenu [4].Frame.Width / 2 + 15, listMenu [4].Frame.Height / 2 + 30);
			listMenu [4].Add (titleJobs);
			listMenu [4].Add (cmdjobsh);
 
			UIButton cmdCus = new UIButton (UIButtonType.Custom);
			UIImage imageCus = PosUtility.ImageFrom("cus_1");
			UIImage imageCusTouched = PosUtility.ImageFrom("cus_2");
			cmdCus.SetBackgroundImage (imageCus,UIControlState.Normal);
			cmdCus.SetBackgroundImage (imageCusTouched,UIControlState.Highlighted);
			cmdCus.Frame = new RectangleF (0, 0, 50, 50);
			cmdCus.Center = new PointF (listMenu [5].Frame.Width / 2, listMenu [5].Frame.Height / 2);
			UILabel titleCus = new UILabel (new RectangleF ( 0, 0, 100, 30));
			titleCus.Text="Customers";
			titleCus.Font=UIFont.SystemFontOfSize (14f);
			titleCus.TextColor = UIColorExtensions.FromHexString("#929292");
			titleCus.LineBreakMode=UILineBreakMode.WordWrap;
			titleCus.Center = new PointF (listMenu [5].Frame.Width / 2 + 15, listMenu [5].Frame.Height / 2 + 30);
			listMenu [5].Add (titleCus);
			listMenu [5].Add (cmdCus);

			// row 3

			UIButton cmdSta = new UIButton (UIButtonType.Custom);
			UIImage imageSta = PosUtility.ImageFrom ("sta_1");
			UIImage imageStaTouched = PosUtility.ImageFrom ("sta_2");
			cmdSta.SetBackgroundImage (imageSta,UIControlState.Normal);
			cmdSta.SetBackgroundImage (imageStaTouched,UIControlState.Highlighted);
			cmdSta.Frame = new RectangleF (0, 0, 50, 50);
			cmdSta.Center = new PointF (listMenu [6].Frame.Width / 2, listMenu [6].Frame.Height / 2);
			UILabel titleSta = new UILabel (new RectangleF ( 0, 0, 100, 30));
			titleSta.Text="Employees";
			titleSta.TextColor = UIColorExtensions.FromHexString("#929292");
			titleSta.Font=UIFont.SystemFontOfSize (14f);
			titleSta.Center = new PointF (listMenu [6].Frame.Width / 2 + 15, listMenu [6].Frame.Height / 2 + 30);
			listMenu [6].Add (titleSta);
			listMenu [6].Add (cmdSta);

			UIButton cmdGif = new UIButton (UIButtonType.Custom);
			UIImage imageGif = PosUtility.ImageFrom ("gif_1");
			UIImage imageGifTouched = PosUtility.ImageFrom("gif_2");
			cmdGif.SetBackgroundImage (imageGif,UIControlState.Normal);
			cmdGif.SetBackgroundImage (imageGifTouched,UIControlState.Highlighted);
			cmdGif.Frame = new RectangleF (0, 0, 50, 50);
			cmdGif.Center = new PointF (listMenu [7].Frame.Width / 2, listMenu [7].Frame.Height / 2);
			UILabel titleGift1 = new UILabel (new RectangleF ( 0, 0, 100, 60));
			titleGift1.Text="Gift Card";
			titleGift1.TextColor = UIColorExtensions.FromHexString("#929292");
			titleGift1.Font=UIFont.SystemFontOfSize (14f);
			titleGift1.Center = new PointF (listMenu [7].Frame.Width / 2 + 20, listMenu [7].Frame.Height / 2 + 30);

			UILabel titleGift2 = new UILabel (new RectangleF ( 0, 0, 100, 60));
			titleGift2.Text="Management";
			titleGift2.TextColor = UIColorExtensions.FromHexString("#929292");
			titleGift2.Font=UIFont.SystemFontOfSize (14f);
			titleGift2.Center = new PointF (listMenu [7].Frame.Width / 2 + 10, listMenu [7].Frame.Height / 2 + 50);
			listMenu [7].Add (titleGift1);
			listMenu [7].Add (titleGift2);
			listMenu [7].Add (cmdGif);

			UIButton cmdRep = new UIButton (UIButtonType.Custom);
			UIImage imageRep = PosUtility.ImageFrom ("rep_1");
			UIImage imagerepTouched = PosUtility.ImageFrom("rep_2");
			cmdRep.SetBackgroundImage (imageRep,UIControlState.Normal);
			cmdRep.SetBackgroundImage (imagerepTouched,UIControlState.Highlighted);
			cmdRep.Frame = new RectangleF (0, 0, 50, 50);
			cmdRep.Center = new PointF (listMenu [8].Frame.Width / 2, listMenu [8].Frame.Height / 2);
			UILabel titleRep = new UILabel (new RectangleF ( 0, 0, 100, 30));
			titleRep.Text="Reports";
			titleRep.Font=UIFont.SystemFontOfSize (14f);
			titleRep.TextColor = UIColorExtensions.FromHexString("#929292");
			titleRep.Center = new PointF (listMenu [8].Frame.Width / 2 + 25, listMenu [8].Frame.Height / 2 + 30);
			listMenu [8].Add (titleRep);
			listMenu [8].Add (cmdRep);

			//row 4

			UIButton cmdInv = new UIButton (UIButtonType.Custom);
			UIImage imageInv = PosUtility.ImageFrom("inv_1");
			UIImage imageInvTouched = PosUtility.ImageFrom("inv_2");
			cmdInv.SetBackgroundImage (imageInv,UIControlState.Normal);
			cmdInv.SetBackgroundImage (imageInvTouched,UIControlState.Highlighted);
			cmdInv.Frame = new RectangleF (0, 0, 50, 50);
			cmdInv.Center = new PointF (listMenu [9].Frame.Width / 2, listMenu [9].Frame.Height / 2);
			cmdInv.TouchUpInside += (object sender, EventArgs e) => {
				NavController.PushViewController(new MenuLeftVCtrl(),false);
				SidebarController.CloseMenu();
			};
			UILabel titleInv = new UILabel (new RectangleF ( 0, 0, 100, 30));
			titleInv.Text="Inventory";
			titleInv.Font=UIFont.SystemFontOfSize (14f);
			titleInv.TextColor = UIColorExtensions.FromHexString("#929292");
			titleInv.Center = new PointF (listMenu [9].Frame.Width / 2 + 20, listMenu [9].Frame.Height / 2 + 30);

			cmdInv.TouchDown += (object sender, EventArgs e) => {
				titleInv.TextColor= UIColorExtensions.FromHexString("##ff475f");
  			};
			cmdInv.TouchUpOutside += (object sender, EventArgs e) => {
				titleInv.TextColor = UIColorExtensions.FromHexString("#929292");
			};
			listMenu [9].Add (titleInv);
			listMenu [9].Add (cmdInv);

			UIButton cmdSet = new UIButton (UIButtonType.Custom);
			UIImage imageSet = PosUtility.ImageFrom ("set_1");
			UIImage imageSetTouched = PosUtility.ImageFrom ("set_2");
			cmdSet.SetBackgroundImage (imageSet,UIControlState.Normal);
			cmdSet.SetBackgroundImage (imageSetTouched,UIControlState.Highlighted);
			cmdSet.Frame = new RectangleF (0, 0, 50, 50);
			cmdSet.Center = new PointF (listMenu [10].Frame.Width / 2, listMenu [10].Frame.Height / 2);

			UILabel titleSet = new UILabel (new RectangleF ( 0, 0, 100, 30));
			titleSet.Text="Settings";
			titleSet.TextColor = UIColorExtensions.FromHexString("#929292");
			titleSet.Center = new PointF (listMenu [10].Frame.Width / 2 + 25, listMenu [10].Frame.Height / 2 + 30);
			titleSet.Font=UIFont.SystemFontOfSize (14f);
			listMenu [10].Add (titleSet);
			listMenu [10].Add (cmdSet);

			 
			ContentMenu.AddSubviews (listMenu);
			//View.Add (ContentMenu);
			View.Add(title);
			View.Add (ContentMenu);
			//UIImageViewView.Add(body);
			//View.Add(avatar);
			//View.Add(contentButton);
		}
	}
}

